<template>
  <div>
    <ChatPageHead />
    <div class="chat-body-box">
      <ChatPageList ref="target" />
      <router-view @userId="routerView"></router-view>
    </div>
    <ChangeLanguage />
    <BackUp />
  </div>
</template>

<script>
  import ChatPageList from "./ChatPage-List"
  import ChatPageHead from "./ChatPage-Head"
  import BackUp from '../../common/BackUp'
  import ChangeLanguage from '../../common/ChangeLanguage'
    export default {
        name: "Chat",
        components:{
            ChatPageList,
            ChatPageHead,
            ChangeLanguage,
            BackUp
        },
        // 已弃用
        // beforeCreate: function () {
        //     this.axios.post('http://localhost:8081/loginReg/weatherLogin').then(res=>{
        //         if (res.data == false) {
        //             this.$router.push('/loginRegistrationPage')
        //         }
        //     }).catch(
        //         exception=>{
        //             this.$router.push('/loginRegistrationPage')
        //         }
        //     )
        // },
        methods:{
            routerView(val){
                this.$refs.target.setUserId(val)
            },

            reloadingList(userId){
                this.$refs.target.getChatList(userId)
            },

            reloadOnlineUser(arr){
                this.$refs.target.setOnlineUser(arr)
            }
        }
    }
</script>

<style scoped>
  .chat-body-box{
    width: 1000px;
    height: 500px;
    border-radius: 10px;
    overflow: hidden;
    margin: 70px auto;
    margin-bottom: 0px;
  }
</style>
